<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Pipes</title>
<link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../../boost_asio.html" title="Boost.Asio">
<link rel="up" href="../overview.html" title="Overview">
<link rel="prev" href="files.html" title="Files">
<link rel="next" href="serial_ports.html" title="Serial Ports">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td>
<td align="center"><a href="../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="files.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../overview.html"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../boost_asio.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="serial_ports.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="boost_asio.overview.pipes"></a><a class="link" href="pipes.html" title="Pipes">Pipes</a>
</h3></div></div></div>
<p>
        Boost.Asio provides support for portable anonymous pipes on POSIX and Windows
        (when I/O completion ports are available). For example, to create and use
        a connected pair of pipe objects:
      </p>
<pre class="programlisting"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">asio</span><span class="special">::</span><span class="identifier">readable_pipe</span> <span class="identifier">read_end</span><span class="special">(</span><span class="identifier">my_io_context</span><span class="special">);</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">asio</span><span class="special">::</span><span class="identifier">writable_pipe</span> <span class="identifier">write_end</span><span class="special">(</span><span class="identifier">my_io_context</span><span class="special">);</span>
<span class="identifier">boost</span><span class="special">::</span><span class="identifier">asio</span><span class="special">::</span><span class="identifier">connect_pipe</span><span class="special">(</span><span class="identifier">read_end</span><span class="special">,</span> <span class="identifier">write_end</span><span class="special">);</span>

<span class="identifier">write_end</span><span class="special">.</span><span class="identifier">async_write_some</span><span class="special">(</span><span class="identifier">my_write_buffer</span><span class="special">,</span>
    <span class="special">[](</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">system</span><span class="special">::</span><span class="identifier">error_code</span> <span class="identifier">e</span><span class="special">,</span> <span class="identifier">size_t</span> <span class="identifier">n</span><span class="special">)</span>
    <span class="special">{</span>
      <span class="comment">// ...</span>
    <span class="special">});</span>

<span class="identifier">read_end</span><span class="special">.</span><span class="identifier">async_read_some</span><span class="special">(</span><span class="identifier">my_read_buffer</span><span class="special">,</span>
    <span class="special">[](</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">system</span><span class="special">::</span><span class="identifier">error_code</span> <span class="identifier">e</span><span class="special">,</span> <span class="identifier">size_t</span> <span class="identifier">n</span><span class="special">)</span>
    <span class="special">{</span>
      <span class="comment">// ...</span>
    <span class="special">});</span>
</pre>
<h5>
<a name="boost_asio.overview.pipes.h0"></a>
        <span class="phrase"><a name="boost_asio.overview.pipes.see_also"></a></span><a class="link" href="pipes.html#boost_asio.overview.pipes.see_also">See
        Also</a>
      </h5>
<p>
        <a class="link" href="../reference/basic_readable_pipe.html" title="basic_readable_pipe">basic_readable_pipe</a>,
        <a class="link" href="../reference/basic_writable_pipe.html" title="basic_writable_pipe">basic_writable_pipe</a>,
        <a class="link" href="../reference/connect_pipe.html" title="connect_pipe">connect_pipe</a>, <a class="link" href="../reference/readable_pipe.html" title="readable_pipe">readable_pipe</a>, <a class="link" href="../reference/writable_pipe.html" title="writable_pipe">writable_pipe</a>.
      </p>
</div>
<div class="copyright-footer">Copyright © 2003-2024 Christopher M. Kohlhoff<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
      </p>
</div>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="files.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../overview.html"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../boost_asio.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="serial_ports.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
